import { useRoute } from '@react-navigation/native'
import { RootStackParamList } from '@NAVIGATION/NavigationType'
import { NativeStackScreenProps } from '@react-navigation/native-stack'

function useParams<RouteName extends keyof RootStackParamList>():
  Readonly<RootStackParamList[RouteName]> {
  const router = useRoute<NativeStackScreenProps<RootStackParamList,
    RouteName>['route']>()
  return router?.params as RootStackParamList[RouteName]
}

export default useParams
